package com.tinckay;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author Jean
 * @Desc Swagger 配置类
 */
@EnableSwagger2
@Configuration
public class Swagger2 {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tinckay.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact("Jean", "http://localhost:35250/swagger-ui.html", "yuanjie@tinckay.com");
        return new ApiInfoBuilder()
                .title("砼智能浇筑系统API")
                .description("©2018 Copyright. Powered By Jean.")
                .termsOfServiceUrl("localhost:8080/swagger-ui.htm")
                .contact(contact)
                .version("1.0.0-SNAPSHOT")
                .build();
    }

}
